start <- Sys.time()
# Load packages
pkgs <- c("tidyverse", "ggpubr", "latex2exp", "rlist", "xtable", "gridExtra", "mpoly", "moments")

for (pkg in pkgs) {
  if (!require(pkg, character.only = TRUE)) {
    install.packages(pkg)
    library(pkg, character.only = TRUE)
  }
}

# Load Privacy Unbiased Package
devtools::install_github("georgieevans/PrivacyUnbiased")
library(PrivacyUnbiased)

# Functions to run main simulations
source('simulation_functions.R')

# Run main simulations
message('Running main simulations')
source('main_simulation_run.R')

# Run time test 

message('Running variance time test')
source('variance_time.R')

# Generate main figures

message('Generating main figures')
source('main_figures.R')

# Run application 

message('Running empirical appliciation code')
source('application.R')

# DP histograms
message('Running DP histograms code')
source('distributions.R')

# DP reg diagnostics
message('Running DP regression diagnostics code')
source('diagnostics.R')


end <- Sys.time()